import api from '../../axios/axios';
import type { Tag } from '../../dto/problemManagement';

// 标签管理相关接口
export interface TagListResponse {
  code: number;
  message: string;
  data: Tag[];
}

export interface TagCreateRequest {
  name: string;
  color: string;
  oj: string;
  gid?: number | null;
  tcid?: number | null;
}

export interface TagCreateResponse {
  code: number;
  message: string;
  data: Tag;
}

// 标签管理API
export const tagManagementApi = {
  // 获取标签列表
  getTagList: (): Promise<TagListResponse> => {
    return api.get('/admin/problem-tag/list');
  },

  // 创建标签
  createTag: (data: TagCreateRequest): Promise<TagCreateResponse> => {
    return api.post('/admin/problem-tag/', data);
  },

  // 删除标签
  deleteTag: (id: number): Promise<{ code: number; message: string }> => {
    return api.delete(`/admin/problem-tag/${id}`);
  },

  // 更新标签
  updateTag: (id: number, data: Partial<TagCreateRequest>): Promise<TagCreateResponse> => {
    return api.put(`/admin/problem-tag/${id}`, data);
  }
};

export default tagManagementApi;